package com.yidu.t299.dao.ljc;
import com.yidu.t299.domain.ljc.Instoreroom;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/10 9:22
 */
@Mapper
public interface InstoreroomMapper {
    /**
     * 增加
     * @param record
     * @return
     */
    @Insert({
            "insert into in_storeroom (in_id,in_name,in_price,in_number,advise_number,stock_id,booker_id,in_date)" +
                    " values " +
                    "(#{inId,jdbcType=INTEGER}, #{inName,jdbcType=VARCHAR}," +
                    "#{inPrice,jdbcType=DOUBLE},#{inNumber,jdbcType=INTEGER}," +
                    "#{adviceNum,jdbcType=INTEGER},#{stockId,jdbcType=INTEGER}," +
                    "#{bookerId,jdbcType=INTEGER},#{inDate,jdbcType=VARCHAR})"
    })
    int insert(Instoreroom record);

    /**
     * 删除
     * @param inId
     * @return
     */
    @Delete({
            "delete from in_storeroom" +
                    " where in_id = #{inId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer inId);

    /**
     * 修改
     * @param record
     * @return
     */
    @Update({
            "update in_storeroom"+
            " set in_name = #{inName,jdbcType=VARCHAR},"+
                    "in_price = #{inPrice,jdbcType=DOUBLE},"+
                    "in_number = #{inNumber,jdbcType=INTEGER},"+
                    "advise_number = #{adviceNum,jdbcType=INTEGER},"+
                    "stock_id = #{stockId,jdbcType=INTEGER},"+
                    "booker_id = #{bookerId,jdbcType=INTEGER},"+
                    "in_date = #{inDate,jdbcType=VARCHAR}"+
                    " where in_id = #{inId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Instoreroom record);

    /**
     * 查询
     * @param inId
     * @return
     */
    @Select({
            "select" +
                    "in_id,in_name,in_price,in_number,advise_number,stock_id,booker_id,in_date" +
                    " from in_storeroom" +
                    " where in_id = #{inId,jdbcType=INTEGER}"
    })
    @Results(id = "InstoreroomMap",value = {
            @Result(id = true,column = "in_id",property = "inId"),
            @Result(column = "in_name",property = "inName"),
            @Result(column = "in_price",property = "inPrice"),
            @Result(column = "in_number",property = "inNumber"),
            @Result(column = "advise_number",property = "adviceNum"),
            @Result(column = "stock_id",property = "stockId"),
            @Result(column = "booker_id",property = "bookerId"),
            @Result(column = "in_date",property = "inDate")
    })
    Instoreroom selectByPrimaryKey(Integer inId);

    /**
     * 分页查询数据信息
     * @param rows
     * @param page
     * @param condition
     * @return
     */
    @Select("select * from in_storeroom where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("InstoreroomMap")
    List<Instoreroom> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 条件查询数据
     * @param condition
     * @return
     */
    @Select("select count(*) from in_storeroom where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

}
